package com.joeyzh.table;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.joey.base.BaseModel;
import com.joey.ui.CheckedModel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Joey on 2018/12/26.
 *
 * @author by Joey
 *         抽象的检查项
 *         用于动态加载布局之类的
 */

public class TableLogItemEntity {

    public static final String SPIT = "##";

    /**
     * 类型
     */
    @SerializedName(value = "Type", alternate = {"WidgetType"})
    String Type;
    /**
     * 数值
     */
    @Expose()
    @SerializedName(value = "ParamValue", alternate = {"ContentValue"})
    String ParamValue;
    /**
     * 提交的名称
     */
    @Expose()
    @SerializedName(value = "ParamNId", alternate = {"ParamCode", "FormWidgetNId","NId"})
    String ParamCode;
    /**
     * 标签文本
     */
    @SerializedName(value = "Text", alternate = {"Name"})
    String Text;

    /**
     * 数据源
     */
    List<? extends CheckedModel> Items = new ArrayList<>();
    /**
     * 操作者，签名
     */
    String ParamOperator;
    ArrayList ParamArray;
    /**
     * 是否是必填参数 YES 表示非必填
     */
    String isRequired;
    /**
     * 下划线重点强调内容
     */
    String UnderLine;
    /**
     * 表示组件是否可编辑
     */
    boolean enable = true;

    /**
     * 其他内容说明
     */
    @SerializedName(value = "Extra", alternate = {"Config"})
    String Extra;

    HashMap<String, Object> configEntry;


    public TableLogItemEntity(String paramValue, String paramCode) {
        ParamValue = paramValue;
        ParamCode = paramCode;
    }

    public TableLogItemEntity() {
    }

    public String getType() {
        return Type;
    }

    public void setType(String type) {
        Type = type;
    }

    public String getParamValue() {
        return ParamValue;
    }

    public void setParamValue(String ParamValue) {
        this.ParamValue = ParamValue;
    }

    public String getParamCode() {
        return ParamCode;
    }

    public void setParamCode(String ParamCode) {
        this.ParamCode = ParamCode;
    }

    public String getText() {
        return Text;
    }

    public void setText(String text) {
        Text = text;
    }

    public List<? extends CheckedModel> getItems() {
        return Items;
    }

    public void setItems(List<? extends CheckedModel> items) {
        Items = items;
    }

    public String getParamOperator() {
        return ParamOperator;
    }

    public void setParamOperator(String paramOperator) {
        ParamOperator = paramOperator;
    }

    public ArrayList getParamArray() {
        return ParamArray;
    }

    public void setParamArray(ArrayList paramArray) {
        ParamArray = paramArray;
    }

    public String isRequired() {
        return isRequired;
    }

    public void setRequired(String required) {
        isRequired = required;
    }

    public String getUnderLine() {
        return UnderLine;
    }

    public void setUnderLine(String underLine) {
        UnderLine = underLine;
    }

    public String getExtra() {
        return Extra;
    }

    public void setExtra(String extra) {
        Extra = extra;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public HashMap<String, Object> getConfigEntry() {
        return configEntry;
    }

    public void setConfigEntry(HashMap<String, Object> configEntry) {
        this.configEntry = configEntry;
    }

    public void parseConfig() {
        if (TextUtils.isEmpty(getExtra())) {
            setConfigEntry(new HashMap<String, Object>());
            return;
        }
        setType(ComponentType.parseConfig(getExtra()).toString());
        try {
            setConfigEntry(new Gson().fromJson(getExtra(), HashMap.class));
        } catch (Exception e) {

        }
    }

    /**
     * 配置信息
     */
    public static class ConfigBean extends BaseModel {

        /**
         * Type : 5
         * IsRequired : true
         * SingleSelectType : Query
         * appName : Exception
         * entityName : EquipmentConfiguration
         * OptionLabel : Name
         * OptionValue : Id
         * OptionConfig : ''
         */

        private String Type;
        private String IsRequired;
        private String SingleSelectType;
        private String appName;
        /**
         * 实体名称
         */
        private String entityName;
        /**
         * Name
         */
        private String OptionLabel;
        /**
         * Code
         */
        private String OptionValue;
        /**
         * odata筛选内容
         */
        private String OptionConfig;

        public String getType() {
            return Type;
        }

        public void setType(String Type) {
            this.Type = Type;
        }

        public String getIsRequired() {
            return IsRequired;
        }

        public void setIsRequired(String IsRequired) {
            this.IsRequired = IsRequired;
        }

        public String getSingleSelectType() {
            return SingleSelectType;
        }

        public void setSingleSelectType(String SingleSelectType) {
            this.SingleSelectType = SingleSelectType;
        }

        public String getAppName() {
            return appName;
        }

        public void setAppName(String appName) {
            this.appName = appName;
        }

        public String getEntityName() {
            return entityName;
        }

        public void setEntityName(String entityName) {
            this.entityName = entityName;
        }

        public String getOptionLabel() {
            return OptionLabel;
        }

        public void setOptionLabel(String OptionLabel) {
            this.OptionLabel = OptionLabel;
        }

        public String getOptionValue() {
            return OptionValue;
        }

        public void setOptionValue(String OptionValue) {
            this.OptionValue = OptionValue;
        }

        public String getOptionConfig() {
            return OptionConfig;
        }

        public void setOptionConfig(String OptionConfig) {
            this.OptionConfig = OptionConfig;
        }
    }


}
